namespace FIREFLYX {
    /** 实体原始类型 */
    export enum GameObjectPrimitiveType {
        /** 正方体 */
        CUBE,
        /** 正四边形 */
        QUAD,
        /** 正球体 */
        SPHERE,
        /** 圆柱体体 */
        CYLINDER,
    }

    export class GameObjectUtil {

        /**
         * 创建一个原始样式实体
         * @param pType 原始样式类型
         */
        public static createPrimitive(pType: GameObjectPrimitiveType) {
            let mType: DefMesh = DefMesh.CUBE;
            //初始化资源
            switch (pType) {
                case GameObjectPrimitiveType.CUBE: mType = DefMesh.CUBE; break;
                case GameObjectPrimitiveType.QUAD: mType = DefMesh.QUAD; break;
                case GameObjectPrimitiveType.SPHERE: mType = DefMesh.SPHERE; break;
                case GameObjectPrimitiveType.CYLINDER: mType = DefMesh.CYLINDER; break;
                default:
            }

            let m: Mesh = DefaultAsset.GetMesh(mType as DefMesh);

            const result = new GameObject(DefMesh[mType]);
            const mr = result.addComponent<MeshRenderer>(MeshRenderer) as MeshRenderer;
            mr.mesh = m;
            mr.materialGroup[0] = DefaultAsset.GetMaterial(DefMaterial.MODEL);
            mr.materialGroup[1] = DefaultAsset.GetMaterial(DefMaterial.SHADOW_MAP);

            return result;
        }
    }
}